/**
 * 退出登录
 */
function loginout() {
	if (confirm('确定退出?')) {
		window.location.href = "/shop/login/pages-login.html";
	}
}

$(function() {
    debugger;
	//查询菜单权限
    $(".sub-menu").hide();
    $(".sub-menu ul li").hide();

    var staffId = $("#staffId").val();
    if(staffId== ""){
        top.location.href= "/shop/login/pages-login.html";
        return;
    }

    var param= {

        staffId:$("#staffId").val()==""?"1":$("#staffId").val()
    };
    Ajax.ajax({
        url:"/staff/queryMenuByStaffId",
        data: param,
        type: "POST",
        dataType: 'json',
        async:false,
        success:function(res){
            debugger;

            if (res.resultCode == 0) {
                for(var i=0;i< res.data.length ;i++){
                    var menuCode = res.data[i].menu_code;

                    $("#"+menuCode).parents(".sub-menu").show();
                    $("#"+menuCode).show();
                }


            }else{
            }
        }

    });



	$('#mainframe').load('/shop/index/welcome.html');
	debugger;
	$(".sub-menu li", $('#leftside-navigation')).click(
		function() {
			var id = $(this).attr("id");
			var directory = '';
			switch (id){
				case 'brand':$('#mainframe').load('/shop/offer/brand/list.html');break;
				case 'offertype': $('#mainframe').load('/shop/offer/type/list.html');break;
				case 'spec':$('#mainframe').load('/shop/offer/spec/list.html');break;
				case 'addMarket':$('#mainframe').load('/shop/offer/market/market.html');break;
				case 'marketList':$('#mainframe').load('/shop/offer/market/list.html');break;
				case 'addOffer':$('#mainframe').load('/offer/addOfferInit');break;
				case 'offerList':$('#mainframe').load('/offer/initList');break;
				case 'userList':$('#mainframe').load('/shop/user/list.html');break;
				case 'orderList':$('#mainframe').load('/shop/order/list.html');break;
				case 'suggest':$('#mainframe').load('/shop/suggestion/list.html');break;
				case 'aboutUs':$('#mainframe').load('/aboutUs/init');break;
				case 'addArticle':$('#mainframe').load('/article/addInit');break;
				case 'articles':$('#mainframe').load('/shop/article/list.html');break;
				case 'staff-list':$('#mainframe').load('/shop/staff/admin.html');break;
                case 'others':$('#mainframe').load('/config/initConfig');break;


			}
		});
});